#ifndef LOGINFORM_H
#define LOGINFORM_H

#include "csballfm.h"
#include "ballmdl.h"

class LineEdit : public QLineEdit
{
    Q_OBJECT

private:

protected:
    void keyPressEvent(QKeyEvent *e);
    void mousePressEvent(QMouseEvent *mouse);

public:
    LineEdit(QWidget *parent = 0L);

signals:
    void mouseClick();
    void tabPressed();
    void enterPressed();
};
//---------------------------------------------------------------------------

class EditWindow : public QWidget
{
    Q_OBJECT

private:
    LineEdit *pEdit;

public:
    explicit EditWindow(QWidget *parent = 0);

    LineEdit* edit() const {return pEdit;}
};
//---------------------------------------------------------------------------

class SLoginForm : public SCustomBallForm
{
    Q_OBJECT

private:
    SBallModel *ballModel;
    EditWindow *snEdit;
    EditWindow *passEdit;

    bool pLoginReady;
    bool pLoginSent;

    void drawInputRect(QImage *img, QRect rect);

protected:
    void setFrame(QRect frame);
    void mousePressEvent(QMouseEvent *mouse);
    void keyPressEvent(QKeyEvent *e);

public:
    explicit SLoginForm(QWidget *parent = 0);
    
signals:
    void loginRequest(QString uin, QString password);

private slots:
    void onTimer(QObject *sender);
    void onBounce(SBounceEdges edges);
//    void onBallReady();
//    void onClose();
    void changeFocus();
    void stopBall();

protected slots:
    void PaintBack(QImage *img);
    void onCtrlEnter();
    
public slots:
    
};

#endif // LOGINFORM_H
